If Window Exists Action Icon

If Window Exists Action

Declaration

<AMIFWINDOWEXISTS ACTION="close" WINDOWTITLE="text" ALLOWHIDDEN="YES" WINDOWHANDLEVARIABLE="test [variable]" {also accepts all standard Window Dissection parameters}>

</AMIF>

See Also

Focus Window, Maximize Window, Minimize Window, Restore Window, Hide Window, Unhide Window, Resize Window, Move Window, Wait for Window, End Process

Description

Causes the steps following this action to execute if the specified window is in the specified state. If not, execution follows the next Else or End If action, whichever comes first.

Practical Usage

To check if a folder is opened, closed, or focused and take conditional action depending on the result.

Parameters

General Tab

If
Text, Optional Default: exist)
MARKUP: ACTION="close"

Specifies the type of check to be performed..

The available options are:

open:  The IF block will be executed if the window is open

close: The IF block will be executed if the window is not open.

focus: The IF block will be executed if the window is opened and focused.

background: The IF block will be executed if the window is open but not focued (in the background).

Window Title
Text, Required
MARKUP:
a) WINDOWTITLE="Untitled - Notepad"

Specifies the title of the Window to check. The value is case-insensitive. This parameter supports wildcards (* and ?), for example "*Internet Explorer* would include all Windows containing that text. Note: If this parameter is left blank the action assumes it is searching for a Window title that is blank - to ignore the WIndow title, use *.

Window Class
Text, Required
MARKUP: WINDOWCLASS="Outlook Express Browser Class"

Specifies the class of the Window to act on. The value is case-insensitive. This parameter supports wildcards (* and ?), for example "*Internet Explorer* would include all Windows classes containing that text. Note: If this parameter is left blank the action assumes it is searching for a Window class that is blank - to ignore the WIndow class, use *.

Window Handle
Number, Optional - Default - 0
MARKUP: WINDOWHANDLE="555735"

Specifies the handle of the Window to act on. If set to 0 or omitted the parameter is ignored.

Include Hidden Windows
Yes\No, Optional - Default NO
MARKUP: ALLOWHIDDEN="YES"

When enabled, specifies that hidden (non-visible) windows should be included in the window search. By default hidden windows are considered unavailable.

Close Type
Options, Optional - Default "request"
MARKUP: CLOSETYPE="force"

Specifies whether the window will be "requested" to close giving the application the opportunity to clean up and prompt to save - or "forced" to close which could cause the application to loose data.

There are two available options:
request
: Request Close - The system will request the window to close as though the user had clicked the close button. The application will then be able to perform clean up and may prompt the user to save any open work. The application is responsible for handling the close request properly.

force: Force Close - The system will force the window to close which could cause any open applications to lose unsaved data.

Contents Tab

The contents tab contains standard window dissection parameters used to describe controls or text inside a window. These parameters are the same on every action that specifies a window and are documented under Window Dissection Parameters.

Advanced Tab

Populate variable with window handle
Text [variable name], Optional
MARKUP: WINDOWHANDLEVARIABLE="varname"

Specifies the variable to receive the handle of the matching window that was found.

 Notes

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Example

<AMIFWINDOWEXISTS ACTION="focus" WINDOWTITLE="Untitled - Notepad">
<AMMESSAGEBOX>The window is opened and in front</AMMESSAGEBOX>
</AMIF>